package com.cljh.config;

import com.cljh.config.interceptor.JwtInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.MultipartAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * SpringMVC配置类
 */
//@Configuration
//@ComponentScan({"com.cljh.controller", "com.cljh.config"})
public class InterceptorConfig implements WebMvcConfigurer {

    @Autowired
    private JwtInterceptor jwtInterceptor;
    //拦截器配置
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        //添加jwt拦截器
        registry.addInterceptor(jwtInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(
//                        "/admins/**",
                        "/products/export",
                        "/products/import",
                        "/user_products/export",
                        "/users/export",
                        "/imserver/**"
//                        "/products/file/**"
                ); //拦截所有请求，通过判断是否有token决定是否需要登录

    }
    //                        "/file/upload",
    //                        "/file/*",


//    @Bean
//    public JwtInterceptor jwtInterceptor(){
//        return new JwtInterceptor();
//    }



}
